import request from '@/utils/request'
import { getDefaultWhiteList } from 'xss'

export function operatorList(params) {
  return request({
    url: '/online/management/admin/operator', params,
    method: 'GET'
  })
}

export function auditOperatorList(params) {
  return request({
    url: '/online/management/admin/operator/audit/page', params,
    method: 'GET'
  })
}

export function getOperatorInfo(operatorId) {
  return request({
    url: `/online/management/admin/operator/${operatorId}`,
    method: 'GET'
  })
}
export function deleteOperator(operatorId) {
  return request({
    url: `/online/management/admin/operator/pre-delete/${operatorId}`,
    method: 'DELETE'
  })
}
export function getLicenseList(params) {
  return request({
    url: '/online/management/admin/operator/billing/business', params,
    method: 'GET'
  })
}
export function addLicense(data, bizCode) {
  return request({
    url: `/online/management/admin/operator/billing/business/${bizCode}`, data,
    method: 'POST'
  })
}
export function downloadCert(params) {
  return request({
    url: `/online/management/admin/operator/${params}/csr/download`, params,
    method: 'GET'
  })
}
export function examineOperator(data) {
  return request({
    url: `/online/management/admin/operator/${data.operatorId}/examine`, data,
    method: 'POST'
  })
}
export function updateOperatorEmail(userId, data) {
  return request({
    url: `/online/management/admin/operator/${userId}/update/email`, data,
    method: 'POST'
  })
}
export function examineDemoOperator(data) {
  return request({
    url: `/online/management/admin/operator/${data.operatorId}/demoExamine`, data,
    method: 'POST'
  })
}
export function operatorLevelList(params) {
  return request({
    url: '/online/authorization/level/list', params,
    method: 'GET'
  })
}
export function operatorLevelUpdate(data) {
  return request({
    url: '/online/management/admin/operator/level/update', data,
    method: 'POST'
  })
}
// export function resetPassword(keyId) {
//   return request({
//     url: `/online/management/admin/operator/resetPassword/${keyId}`,
//     method: 'POST'
//   })
// }
export function resetPassword(keyId) {
  return request({
    url: `/online/authorization/user/${keyId}/reset/password`,
    method: 'POST'
  })
}
export function configureMap(operatorId, data) {
  return request({
    url: `/online/management/admin/operator/resetMap/${operatorId}`, data,
    method: 'POST'
  })
}
export function systemRegisterDemoOperator(data) {
  return request({
    url: `/online/management/admin/operator/domeOperator`, data,
    method: 'POST'
  })
}
export function getCountryList() {
  return request({
    url: '/online/authorization/country/list', params: { status: 1 },
    method: 'GET'
  })
}
export function getBlackList(params) {
  return request({
    url: '/online/authorization/menu/blacklist/list', params,
    method: 'GET'
  })
}
export function postBlackList(operatorId, data) {
  return request({
    url: `/online/authorization/menu/blacklist/character/OPERATOR/target/${operatorId}`, data,
    method: 'POST'
  })
}
// 获取相关的菜单
export function getOperatorMenuList(params) {
  return request({
    url: '/online/authorization/admin/menu/all', params,
    method: 'GET'
  })
}
// 获取相关菜单的权限
export function getOperatorMenuFunctionList(params) {
  return request({
    url: '/online/authorization/admin/menu/function/all', params,
    method: 'GET'
  })
}
export function configure(operatorId, data) {
  return request({
    url: `/online/management/admin/operator/configure/${operatorId}`, data,
    method: 'POST'
  })
}
export function getConfigure(operatorId) {
  return request({
    url: `/online/management/admin/operator/configure/${operatorId}`,
    method: 'GET'
  })
}
export function getaccountList(params) {
  return request({
    url: `/online/authorization/admin/user/account-list`, params,
    method: 'GET'
  })
}

export function getaccountPage(params) {
  return request({
    url: `/online/authorization/admin/user/accounts`, params,
    method: 'GET'
  })
}

/**  分页查询加了一个参数：currentlyEffect-生效标识
      // -1：查询当前生效余额（）
      // 0：查询未过期余额
      // 1：查询所有余额，包含过期、当前生效、未生效
*/
export function getFlyDeskRemainTime(operatorId, params) {
  return request({
    url: `/online/management/admin/operator/flydesk/${operatorId}`,
    method: 'GET',
    params
  })
}

export function getFlyDeskByResType(resType, operatorId, params) {
  return request({
    url: `/online/management/admin/operator/flydesk/${resType}/${operatorId}`,
    method: 'GET',
    params
  })
}
export function getRemindEmail() {
  return request({
    url: `/online/management/admin/operator/remind`,
    method: 'GET'
  })
}
export function saveRemindEmail(data) {
  return request({
    url: `/online/management/admin/operator/remind`, data,
    method: 'POST'
  })
}
export function deleteRemindEmail(id) {
  return request({
    url: `/online/management/admin/operator/remind/${id}`,
    method: 'DELETE'
  })
}
export function updateRemindEmail(id, data) {
  return request({
    url: `/online/management/admin/operator/remind/${id}`, data,
    method: 'POST'
  })
}

export function addOperator(data) {
  return request({
    url: `/online/management/admin/operator/cert-file`,
    method: 'POST',
    data
  })
}

export function checkCert(data) {
  return request({
    url: `/online/management/admin/operator/parse-cert`,
    method: 'POST',
    data
  })
}

export function checkOperator(operatorCertId, data) {
  return request({
    url: `/online/management/admin/operator/${operatorCertId}/cert-file`,
    method: 'POST',
    data
  })
}

export function getDownloadTransferPathList() {
  return request({
    url: `/online/management/admin/operator/download-transfer-path/list`,
    method: 'GET'
  })
}

export function getOperatorDownloadTransferPath(operatorId) {
  return request({
    url: `/online/management/admin/operator/download-transfer-path/${operatorId}`,
    method: 'GET'
  })
}

export function addOrUpdateOperatorDownloadTransferPath(data) {
  return request({
    url: `/online/management/admin/operator/download-transfer-path/add-or-update`,
    method: 'POST',
    data
  })
}

export function getOaCustomerList(data) {
  return request({
    url: `/online/management/admin/operator/oa-customer/list`,
    method: 'POST',
    data
  })
}

export function getOperatorOuterBindInfo(operatorId) {
  return request({
    url: `/online/management/admin/operator/outer-bind-info/${operatorId}`,
    method: 'GET'
  })
}

export function bindOACustomer(data) {
  return request({
    url: `/online/management/admin/operator/oa-customer/bind/add-or-update`,
    method: 'POST',
    data
  })
}

export function getOperatorActivity(operatorId, params) {
  return request({
    url: `/online/management/statistic/operator/${operatorId}/activity/trend`,
    method: 'GET',
    params
  })
}
export function getOperatorActivityCurMonth(operatorId) {
  return request({
    url: `/online/management/statistic/operator/${operatorId}/activity/current-month`,
    method: 'GET'
  })
}
export function getOperatorDevicecount(operatorId) {
  return request({
    url: `/online/management/statistic/operator/${operatorId}/device/count`,
    method: 'GET'
  })
}

export function getOperatorOnlineDevicecount(params) {
  return request({
    url: `/online/management/statistic/operator/online/device/count`,
    method: 'GET',
    params
  })
}
export function getOperatorOnlineDeviceTrend(data) {
  return request({
    url: `/online/management/statistic/trend/online`,
    method: 'POST',
    data
  })
}
export function getOperatorNewActiveDeviceTrend(data) {
  return request({
    url: `/online/management/statistic/trend/active`,
    method: 'POST',
    data
  })
}

export function getOperatorActivityDevicetrend(params) {
  return request({
    url: `/online/management/statistic/device/active/month/summary`,
    method: 'GET',
    params
  })
}
export function getOperatorAllModels(params) {
  return request({
    url: `/online/management/statistic/query/all/model`,
    method: 'GET',
    params
  })
}
export function getOperatorApplicationTrend(params) {
  return request({
    url: `/online/management/statistic/application/download/count/trend`,
    method: 'GET',
    params
  })
}

export function exportActiveDevices(params) {
  return request({
    url: '/online/management/statistic/device/file/export',
    method: 'get',
    responseType: 'blob',
    params,
    timeout: 1000 * 60 * 10
  })
}

export function getFlyDeskPurchaseHistory(operatorId, params) {
  return request({
    url: `/online/management/admin/operator/flydesk/purchase-history/${operatorId}`,
    method: 'GET',
    params
  })
}
export function getFlyDeskConsumeHistory(operatorId, params) {
  return request({
    url: `/online/management/admin/operator/flydesk/consume-history/${operatorId}`,
    method: 'GET',
    params
  })
}
export function getPlatCode(characterCode) {
  return request({
    url: `/online/authorization/admin/character/${characterCode}/plat-code/all`,
    method: 'GET'
  })
}

export function lockManageOperator(operatorId, lockStatus) {
  return request({
    url: `/online/management/admin/operator/lock/${lockStatus}/${operatorId}`,
    method: 'POST'
  })
}

// 查询黑名单配置
export function getBlackListInfo(params,keyId) {
  return request({
    url: `/online/authorization/admin/operator/menu/func/blacklist/${keyId}`,
    method: 'GET',
    params:params
  })
}

// 查询黑名单配置
export function setBlackListInfo(data) {
  return request({
    url: `/online/authorization/admin/operator/menu/func/blacklist/`,
    method: 'POST',
    data:data
  })
}

// 查询白名单配置
export function getWhiteListInfo(params,keyId) {
  return request({
    url: `/online/authorization/admin/operator/menu/func/whitelist/${keyId}`,
    method: 'GET',
    params:params
  })
}

// 查询白名单配置
export function setWhiteListInfo(data) {
  return request({
    url: `/online/authorization/admin/operator/menu/func/whitelist/`,
    method: 'POST',
    data:data
  })
}
export function getFlyKeyConfigList() {
  return request({
    url: `/online/management/admin/operator/flykey/config/all`,
    method: 'GET'
  })
}

export function getOperatorFlyKeyConfig(operatorId) {
  return request({
    url: `/online/management/admin/operator/${operatorId}/flykey/config`,
    method: 'GET'
  })
}

export function saveOperatorFlyKeyConfig(data) {
  return request({
    url: `/online/management/admin/operator/${data.operatorId}/flykey/config/save`,
    method: 'POST',
    data
  })
}
export function setSales(data) {
  return request({
    url: `/online/authorization/admin/operator/${data.operatorId}/sales`,
    method: 'POST',
    data
  })
}

export function delSales(operatorId, ancillaryId) {
  return request({
    url: `/online/authorization/admin/operator/${operatorId}/sales/${ancillaryId}`,
    method: 'DELETE'
  })
}

export function getSalesList(params) {
  return request({
    url: `/online/authorization/admin/operator/${params.operatorId}/sales`,
    method: 'GET',
    params
  })
}
export function getUnSetSalesList(params) {
  return request({
    url: `/online/authorization/admin/operator/${params.operatorId}/sales-unbind`,
    method: 'GET',
    params
  })
}

// 收费策略、大区、备注修改接口
export function postAncillary(data) {
  return request({
    url: `/online/authorization/admin/operator/ancillary`,
    method: 'POST',
    data
  })
}

// 收费策略、大区、备注接口
export function getAncillary(params) {
  return request({
    url: `/online/authorization/admin/operator/${params.operatorId}/ancillary`,
    method: 'GET',
    params
  })
}
// 收费策略、大区、备注修改接口
export function getRegions(params) {
  return request({
    url: `/online/authorization/admin/operator/regions`,
    method: 'GET',
    params
  })
}

// 查询 2FA 配置

export function get2FAConfig(keyId) {
  return request({
    url: `/online/authorization/admin/otp/config/operator/key/${keyId}`,
    method: 'GET'
  })
}

// 查询 2FA 配置
// * @param keyId*
// @param required 0-不要求，1-强制要求，2-自定义

export function set2FAConfig(keyId, required) {
  return request({
    url: `/online/authorization/admin/otp/config/operator/key/${keyId}/required/${required}`,
    method: 'POST'
  })
}


export function getParameterJsonVersion(operatorId) {
  return request({
    url: `/online/management/admin/operator/${operatorId}/parameter-version`,
    method: 'GET'
  })
}

export function setParameterJsonVersion(data) {
  return request({
    url: `/online/management/admin/operator/parameter-version`,
    method: 'POST',
    data
  })
}

export function fullPublishParameterFile(operatorId) {
  return request({
    url: `/online/management/admin/operator/${operatorId}/parameter/full/publish`,
    method: 'POST'
  })
}

export function queryParameterPublishProgress(operatorId) {
  return request({
    url: `/online/management/admin/operator/${operatorId}/parameter/full/publish/progress`,
    method: 'GET'
  })
}

// 查询 运营商等级 配置
export function getUserLevel(keyId) {
  return request({
    url: `/online/management/admin/operator/${keyId}/level/config`,
    method: 'GET'
  })
}

// 设置 运营商等级 配置
// * @param keyId*
// @param required 0-低等级，1-高等级

export function setUserLevel(keyId, levelCode) {
  return request({
    url: `/online/management/admin/operator/${keyId}/level/${levelCode}`,
    method: 'POST'
  })
}

